﻿@{
    Layout = "";
}
<style>
    .ngdialog.ngdialog-theme-plain .ngdialog-content {
        width: 45% !important;
    }
</style>
<div ng-controller="LevelDetailController">
    <div class="container-fluid" ng-show="!selectProduct" id="AgentInfoUpdateMainViewPanel">
        <div class="row">
            <div class="col-md-12">
                <form name="formValidate" ng-submit="submitForm()" novalidate="" class="form-validate form-horizontal">
                    <!-- START panel-->
                    <div class="panel panel-default" ng-class="{ 'whirl standard': isLoading,'': isLoading }">
                        <div class="panel-body">
                            <fieldset class="b0">
                                <legend>添加资金记录</legend>
                            </fieldset>
                            <fieldset>
                                <div class="form-group">
                                    <label class="col-sm-2 control-label">金额</label>
                                    <div class="col-sm-4">
                                        <label class="radio-inline c-radio">
                                            <input id="inlineradio1" type="radio" name="AmountType" ng-model="AmountType" value="1" checked="checked">
                                            <span class="fa fa-circle"></span>增加
                                        </label>
                                        <label class="radio-inline c-radio">
                                            <input id="inlineradio2" type="radio" name="AmountType" ng-model="AmountType" value="-1">
                                            <span class="fa fa-circle"></span>减少
                                        </label>
                                    </div>
                                </div>
                            </fieldset>
                            <fieldset>
                                <div class="form-group">
                                    <label class="col-sm-2 control-label"></label>
                                    <div class="col-sm-4">
                                        <input maxlength="50" type="number" name="Amount" required="" ng-model="model.Amount" class="form-control" />
                                    </div>
                                </div>
                            </fieldset>
                            <fieldset>
                                <div class="form-group">
                                    <label class="col-sm-2 control-label">积分</label>
                                    <div class="col-sm-4">
                                        <label class="radio-inline c-radio">
                                            <input id="inlineradio1" type="radio" name="PointType" ng-model="PointType" value="1" checked="checked">
                                            <span class="fa fa-circle"></span>增加
                                        </label>
                                        <label class="radio-inline c-radio">
                                            <input id="inlineradio2" type="radio" name="PointType" ng-model="PointType" value="-1">
                                            <span class="fa fa-circle"></span>减少
                                        </label>
                                    </div>
                                </div>
                            </fieldset>
                            <fieldset>
                                <div class="form-group">
                                    <label class="col-sm-2 control-label"></label>
                                    <div class="col-sm-4">
                                        <input maxlength="50" type="number" name="Point" required="" ng-model="model.Point" class="form-control" />
                                    </div>
                                    <div class="col-sm-4">
                                        <h4 class="text-danger">*</h4>
                                    </div>
                                </div>
                            </fieldset>
                            <fieldset>
                                <div class="form-group">
                                    <label class="col-sm-2 control-label">操作备注</label>
                                    <div class="col-sm-4">
                                        <textarea name="Note" placeholder="请输入操作备注" rows="3" class="form-control" ng-model="model.Note"></textarea>
                                    </div>
                                </div>
                            </fieldset>
                        </div>
                        <div class="panel-footer text-right">
                            <button type="button" class="btn btn-warning" ng-click="cancel()">返回列表</button>
                            <button type="button" class="btn btn-primary" ng-click="save()">保存</button>
                        </div>
                    </div>
                    <!-- END panel-->
                </form>
            </div>
        </div>
    </div>
</div>
<script type="text/javascript">
    App.controller('LevelDetailController', ["$scope", "$state", "$http", "$stateParams", "Notify", "$filter",
        function ($scope, $state, $http, $stateParams, Notify, $filter) {
            'use strict';
            $scope.isLoading = false;
            $scope.validateInput = function (name, type) {
                var input = $scope.formValidate[name];
                return (input.$dirty || $scope.submitted) && input.$error[type];
            };



            //数据初始化
            $scope.model = {};
            $scope.model.Point = 0;
            $scope.model.Amount = 0;
            $scope.model.MemberId = $stateParams.id;
            $scope.PointType = 1;
            $scope.AmountType = 1;

            // 提交
            $scope.save = function () {
                $scope.submitted = true;
                $scope.isLoading = true;
                if ($scope.formValidate.$valid) {
                    console.log($scope.PointType)
                    console.log($scope.AmountType)

                    $http.post("/Member/SaveMemberBalanceDetail", { model: $scope.model, pointType: $scope.PointType, amountType: $scope.AmountType }).then(function (returnData) {
                        if (returnData.data.isSuccess) {
                            Notify.alert('操作成功!', { status: 'success' });
                            $state.go("app.recharge", { id: $stateParams.id });
                        } else {
                            Notify.alert(returnData.data.msg, { status: 'warning' });
                            $scope.isLoading = false;
                        }
                    });
                } else {
                    $scope.isLoading = false;
                }
            };

            //返回列表
            $scope.cancel = function () {
                $state.go("app.recharge", { id: $stateParams.id });
            }
        }]);
</script>
